//Edit by AiYan, 11839387

package user.ucm;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import user.model.UserModel;

public class UCDeleting implements UCController {

    private UserModel um;

    public UCDeleting(UserModel um) {
        this.um = um;
    }

    public int run() {
        try{
        Class.forName("com.mysql.jdbc.Driver");

        Connection con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/cp3120?user=root&password=root");
        con.setCatalog("cp3120");

        Statement statement = con.createStatement();
        
        String sql = "DELETE FROM userinfo WHERE UserName = '" + um.getName() + "'";
        System.out.println(sql);
        statement.execute(sql);
        }catch(Exception e){
            e.printStackTrace();
        }
        return 0;
    }
}
